package com.uit.gis.ui;

import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SpringLayout;
import javax.swing.border.TitledBorder;

import com.uit.gis.controller.MainController;
import com.uit.gis.util.Language;

public class PanelAbout extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5642677065756890604L;
	/**
	 * Create the panel.
	 */
	MainController controller;
	JPanel panel;

	public PanelAbout(MainController controller) {
		setToolTipText("About");
		this.controller = controller;
		SpringLayout mainSping = new SpringLayout();
		this.setLayout(mainSping);

		SpringLayout sl_panel = new SpringLayout();
		panel = new JPanel(sl_panel);
		panel.setPreferredSize(new Dimension(700, 250));
		panel.setBorder(new TitledBorder(null, "GIS - Oracle Introduction",
				TitledBorder.LEADING, TitledBorder.TOP, null, null));
		 mainSping.putConstraint(SpringLayout.HORIZONTAL_CENTER, panel, 0,
		 SpringLayout.HORIZONTAL_CENTER, this);
		 mainSping.putConstraint(SpringLayout.VERTICAL_CENTER, panel, 0,
				 SpringLayout.VERTICAL_CENTER, this);
		this.add(panel);

		JLabel lbIntroduction = new JLabel(Language.INTRODUCTION);
		lbIntroduction.setCursor(new Cursor(Cursor.HAND_CURSOR));
		sl_panel.putConstraint(SpringLayout.HORIZONTAL_CENTER, lbIntroduction, 0,
				SpringLayout.HORIZONTAL_CENTER, panel);
		panel.add(lbIntroduction);

		JLabel lblNewLabel_1 = new JLabel(Language.AUTHOR);
		sl_panel.putConstraint(SpringLayout.NORTH, lblNewLabel_1, 33,
				SpringLayout.SOUTH, lbIntroduction);
		sl_panel.putConstraint(SpringLayout.WEST, lblNewLabel_1, 10,
				SpringLayout.WEST, panel);
		panel.add(lblNewLabel_1);

		JLabel lblNewLabel_2 = new JLabel(Language.AUTHOR_DETAIL);
		sl_panel.putConstraint(SpringLayout.NORTH, lblNewLabel_2, 63,
				SpringLayout.SOUTH, lbIntroduction);
		sl_panel.putConstraint(SpringLayout.WEST, lblNewLabel_2, 103,
				SpringLayout.WEST, panel);
		panel.add(lblNewLabel_2);
		lbIntroduction.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                try {
                    Desktop.getDesktop().browse(new URI("https://www.processing.org"));
                } catch (URISyntaxException | IOException ex) {
                    //It looks like there's a problem
                }
            }
        });

	}
}
